package svc

import (
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"video-hub/api/internal/config"
	"video-hub/api/internal/middleware"
	"video-hub/videorpc/videorpcclient"
)

type ServiceContext struct {
	Config config.Config

	VideoRpc videorpcclient.Videorpc

	UserAgentMiddleware rest.Middleware
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config: c,

		VideoRpc: videorpcclient.NewVideorpc(zrpc.MustNewClient(c.VideoRpc)),

		UserAgentMiddleware: middleware.NewUserAgentMiddleware().Handle,
	}
}
